package com.lx.demo2;

import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;


@WebServlet("/s2")
public class ListenerTest extends HttpServlet {

    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException {
        int cnt = (int) req.getSession().getServletContext().getAttribute("cnt");
        PrintWriter out = resp.getWriter();
        out.println("在线人数：" + cnt);
    }
}
